var t = getApp(), a = void 0;

Page({
    data: {
        currentPage: 1,
        pageSize: 10,
        list: [],
        total: 0
    },
    onLoad: function(t) {
        a = this, t.cash && this.setData({
            cash: t.cash
        });
    },
    onShow: function() {
        a.getList(0);
    },
    getList: function(e) {
        0 == e ? this.data.currentPage = 1 : this.data.currentPage += 1, wx.showLoading({
            title: "加载中"
        }), t.com.post("wx/account/list", {
            pageSize: this.data.pageSize,
            currentPage: this.data.currentPage
        }, function(t) {
            wx.stopPullDownRefresh(), wx.hideLoading(), 0 === t.errno && a.setData({
                list: t.data.data,
                total: t.data.count
            });
        });
    },
    onReachBottom: function() {
        this.data.list.length < this.data.total && this.getList(1);
    },
    update: function(t) {
        var a = t.currentTarget.dataset.index;
        wx.navigateTo({
            url: "/pages/runman/cash/banks/edit?url=update&data=" + JSON.stringify(this.data.list[a])
        });
    },
    del: function(e) {
        var i = e.currentTarget.dataset.index;
        wx.showModal({
            title: "提示",
            content: "删除后数据无法恢复，是否要继续删除？",
            success: function(e) {
                e.confirm && (wx.showLoading({
                    title: "删除中",
                    mask: !0
                }), t.com.post("wx/account/recover", {
                    id: a.data.list[i].id
                }, function(t) {
                    wx.hideLoading(), 0 === t.errno && (wx.showToast({
                        title: "删除成功"
                    }), a.getList(0));
                }));
            }
        });
    },
    chooseIt: function(t) {
        var a = t.currentTarget.dataset.index;
        if (this.data.cash) {
            var e = getCurrentPages();
            getCurrentPages()[e.length - 2].setData({
                bankCard: this.data.list[a]
            }), wx.navigateBack({
                delta: 1
            });
        }
    }
});